﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ReconCaracteres_Backpropagation
{
    public partial class CreatePattenForm : Form
    {
      //  public Double[][] matrix;
        public Double[,] matrix = new Double[10, 10];

        public CreatePattenForm()
        {
            InitializeComponent();
         //   this.matrix=new Double[10];
            /*for (int i = 0; i < 10; i++)
            {
                this.matrix[i] = new Double[10];
            }*/
        }

        private void button_Click(object sender, EventArgs e)
        {
            int ejeX = Int32.Parse(((Button)(sender)).Tag.ToString().Substring(0, 1));
            int ejeY = Int32.Parse(((Button)(sender)).Tag.ToString().Substring(1, 1));
            if (Color.Black==((Button)(sender)).BackColor){
                ((Button)(sender)).BackColor = Color.White;

                this.matrix[ejeX,ejeY] = 0;
                
            }else
            {
                ((Button)(sender)).BackColor = Color.Black;
                this.matrix[ejeX,ejeY] = 1;
            }

           // (Button(sender)).
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            
               SaveFileDialog saveFileDialog1 = new SaveFileDialog();
               //saveFileDialog1.Filter = "*.txt";
               saveFileDialog1.Title = "Save a File";
               saveFileDialog1.ShowDialog();

               // If the file name is not an empty string open it for saving.
               if (saveFileDialog1.FileName != "")
               {

                   MyFile f = new MyFile(saveFileDialog1.FileName);
                   f.writeMatrix(this.matrix);
                   f.close();
               }
        }

        private void CrearPatron_Load(object sender, EventArgs e)
        {

        }

        private void button_MouseEnter(object sender, EventArgs e)
        {
            int ejeX = Int32.Parse(((Button)(sender)).Tag.ToString().Substring(0, 1));
            int ejeY = Int32.Parse(((Button)(sender)).Tag.ToString().Substring(1, 1));
            if (Color.Black == ((Button)(sender)).BackColor)
            {
                /* ((Button)(sender)).BackColor = Color.White;
                 */
                //this.matrix[ejeX, ejeY] = 0;

            }
            else
            {
                ((Button)(sender)).BackColor = Color.Black;
                this.matrix[ejeX, ejeY] = 1;
            }
        }

        private void cleanButton_Click(object sender, EventArgs e)
        {
            this.button0.BackColor = Color.White;
            this.button1.BackColor = Color.White;
            this.button2.BackColor = Color.White;
            this.button3.BackColor = Color.White;
            this.button4.BackColor = Color.White;
            this.button5.BackColor = Color.White;
            this.button6.BackColor = Color.White;
            this.button7.BackColor = Color.White;
            this.button8.BackColor = Color.White;
            this.button9.BackColor = Color.White;
            this.button10.BackColor = Color.White;
            this.button11.BackColor = Color.White;
            this.button12.BackColor = Color.White;
            this.button13.BackColor = Color.White;
            this.button14.BackColor = Color.White;
            this.button15.BackColor = Color.White;
            this.button16.BackColor = Color.White;
            this.button17.BackColor = Color.White;
            this.button18.BackColor = Color.White;
            this.button19.BackColor = Color.White;
            this.button20.BackColor = Color.White;
            this.button21.BackColor = Color.White;
            this.button22.BackColor = Color.White;
            this.button23.BackColor = Color.White;
            this.button24.BackColor = Color.White;
            this.button25.BackColor = Color.White; 
            this.button26.BackColor = Color.White;
            this.button27.BackColor = Color.White;
            this.button28.BackColor = Color.White;
            this.button29.BackColor = Color.White;
            this.button30.BackColor = Color.White;
            this.button31.BackColor = Color.White;
            this.button32.BackColor = Color.White;
            this.button33.BackColor = Color.White;
            this.button34.BackColor = Color.White;
            this.button35.BackColor = Color.White;
            this.button36.BackColor = Color.White;
            this.button37.BackColor = Color.White;
            this.button38.BackColor = Color.White;
            this.button39.BackColor = Color.White;
            this.button40.BackColor = Color.White;
            this.button41.BackColor = Color.White;
            this.button42.BackColor = Color.White;
            this.button43.BackColor = Color.White;
            this.button44.BackColor = Color.White;
            this.button45.BackColor = Color.White;
            this.button46.BackColor = Color.White;
            this.button47.BackColor = Color.White;
            this.button48.BackColor = Color.White;
            this.button49.BackColor = Color.White;
            this.button50.BackColor = Color.White;
            this.button51.BackColor = Color.White;
            this.button52.BackColor = Color.White;
            this.button53.BackColor = Color.White;
            this.button54.BackColor = Color.White;
            this.button55.BackColor = Color.White;
            this.button56.BackColor = Color.White;
            this.button57.BackColor = Color.White;
            this.button58.BackColor = Color.White;
            this.button59.BackColor = Color.White;
            this.button60.BackColor = Color.White;
            this.button61.BackColor = Color.White;
            this.button62.BackColor = Color.White;
            this.button63.BackColor = Color.White;
            this.button64.BackColor = Color.White;
            this.button65.BackColor = Color.White;
            this.button66.BackColor = Color.White;
            this.button67.BackColor = Color.White;
            this.button68.BackColor = Color.White;
            this.button69.BackColor = Color.White;
            this.button70.BackColor = Color.White;
            this.button71.BackColor = Color.White;
            this.button72.BackColor = Color.White;
            this.button73.BackColor = Color.White;
            this.button74.BackColor = Color.White;
            this.button75.BackColor = Color.White;
            this.button76.BackColor = Color.White;
            this.button77.BackColor = Color.White;
            this.button78.BackColor = Color.White;
            this.button79.BackColor = Color.White;
            this.button80.BackColor = Color.White;
            this.button81.BackColor = Color.White;
            this.button82.BackColor = Color.White;
            this.button83.BackColor = Color.White;
            this.button84.BackColor = Color.White;
            this.button85.BackColor = Color.White;
            this.button86.BackColor = Color.White;
            this.button87.BackColor = Color.White;
            this.button88.BackColor = Color.White;
            this.button89.BackColor = Color.White;
            this.button90.BackColor = Color.White;
            this.button91.BackColor = Color.White;
            this.button92.BackColor = Color.White;
            this.button93.BackColor = Color.White;
            this.button94.BackColor = Color.White;
            this.button95.BackColor = Color.White;
            this.button96.BackColor = Color.White;
            this.button97.BackColor = Color.White;
            this.button98.BackColor = Color.White;
            this.button99.BackColor = Color.White;
            int a = this.matrix.GetLength(0);
            for (int i = 0; i < this.matrix.GetLength(0);i++ )
            {
                for (int j = 0; j < this.matrix.GetLength(1); j++)
                {
                    this.matrix[i,j] = 0;
                }
            }
        }
    }
}
